package com.neo.pub.config;

import com.syt.service.SendMsgDetileServiceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.namespace.QName;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * sms 配置短信
 * 
 * @author tr
 */
@Configuration
@Slf4j
public class SMSConfig
{

    @Value("${sms.server.address}")
    private String msgAdd;

    @Bean(name = "sendMsgDetileService")
    public SendMsgDetileServiceService getMsgBean(){
        URL url = null;
        try {
            URL baseUrl = SendMsgDetileServiceService.class.getResource(".");
            url = new URL(baseUrl, msgAdd + "/SendMsgWebService/SendMsgDetileServicePort?wsdl");
        } catch (MalformedURLException var2) {
            log.error("Failed to create URL for the wsdl Location: 'http://192.168.88.35:8080/SendMsgWebService/SendMsgDetileServicePort?wsdl', retrying as a local file");
            log.error(var2.getMessage());
        }
        SendMsgDetileServiceService service = new SendMsgDetileServiceService(url,new QName("http://service.syt.com/", "SendMsgDetileServiceService"));
        return service;
    }

}
